function ContentSelector (varName, itemsAreaId, optionsAreaId, itemCssClass, itemSelectedCssClass, itemNameCssClass, itemNameSelectedCssClass, itemsLoadingHTML, renderItemScript, selectedCombinedListKeyId) 
{
	this.VariableName = varName;
	this.ItemsAreaHandle = document.getElementById(itemsAreaId);
	this.OptionsAreaHandle = document.getElementById(optionsAreaId);
	this.SelectedCombinedListKey = document.getElementById(selectedCombinedListKeyId);
	this.ItemCssClass = itemCssClass;
	this.ItemSelectedCssClass = itemSelectedCssClass;
	this.CurrentSelectedItem = null;
	this.CurrentSelectedListKey = null;
	this.ItemsLoadingHTML = itemsLoadingHTML;
	this.RenderItemScript = renderItemScript;
	this.ItemNameCssClass = itemNameCssClass;
	this.ItemNameSelectedCssClass = itemNameSelectedCssClass;
	
	this.GetItems = function (combinedListKey)
	{
		this.CurrentSelectedItem = null;
		this.CurrentSelectedListKey = null;
		this.SelectedCombinedListKey.value = combinedListKey;
		this.ItemsAreaHandle.innerHTML = this.ItemsLoadingHTML;
		
		ContentSelectorAJAX.GetItemsListHTML(this.VariableName, combinedListKey, new Function('result', 'window.' + this.VariableName + '.ShowItems(result);'));
	}
	
	this.ShowItems = function (result)
	{
		this.CurrentSelectedItem = null;
		this.CurrentSelectedListKey = null;

		if (!result.error)
		{
			this.ItemsAreaHandle.innerHTML = result.value[0];
			this.OptionsAreaHandle.innerHTML = result.value[1];
		}
		else
			alert(result.error);
	}
	
	this.SelectItem = function (element, combinedListKey)
	{
		if (this.CurrentSelectedItem != null)
		{
			this.CurrentSelectedItem.childNodes[0].className = this.ItemCssClass;
			this.CurrentSelectedItem.childNodes[1].className = this.ItemNameCssClass;
		}
			
		this.CurrentSelectedItem = element;
		this.CurrentSelectedItem.childNodes[0].className = this.ItemSelectedCssClass;
		this.CurrentSelectedItem.childNodes[1].className = this.ItemNameSelectedCssClass;
		this.CurrentSelectedListKey = combinedListKey;
	}
	
	this.RenderItem = function ()
	{
		if (this.CurrentSelectedListKey)
			ContentSelectorAJAX.GetRenderHTML(this.VariableName, this.CurrentSelectedListKey, new Function('result', 'window.' + this.VariableName + '.RenderItemComplete(result);'));
	}
	
	this.RenderItemComplete = function (result)
	{
		if (!result.error)
		{
			var f = new Function('content', this.RenderItemScript);
			f(result.value);
		}
		else
			alert(result.error);
	}
}
